package com.cdu.guoxinan.www.smartcom.controller;


import com.cdu.guoxinan.www.smartcom.aop.Annotation.OperationLog;
import com.cdu.guoxinan.www.smartcom.domian.vo.DashboardStatVo;
import com.cdu.guoxinan.www.smartcom.domian.vo.StatisticsVo;
import com.cdu.guoxinan.www.smartcom.service.EmpStatisticsService;
import com.cdu.guoxinan.www.smartcom.unit.model.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@RestController
@Api(tags = "数据统计控制器")
@RequestMapping("/empStatistics")
public class EmpStatisticsController {
    @Resource
    private EmpStatisticsService empStatisticsService;
    @GetMapping("/dashboard")
    @ApiOperation("统计")
    @OperationLog(description = "数据统计")
    public R getDashboardStats(){
        //45
        DashboardStatVo stats=empStatisticsService.getDashboardStats();
        return R.ok(stats);
    }

    @GetMapping("/feeTypeDistribution")
    @ApiOperation(" 各费用类型缴纳金额占比图")
    @OperationLog(description = "费用类型分布")
    public R feeTypeDistribution() {
        List<StatisticsVo> list= empStatisticsService.feeTypeDistribution();
        return R.ok(list);
    }
    @GetMapping("/monthlyFeeTrend")
    @ApiOperation("每月维修请求数量趋势图")
    @OperationLog(description = "每月维修请求数量")
    public R maintenanceRequestTrend() {
        List<StatisticsVo> list= empStatisticsService.monthlyFeeTrend();
        return R.ok(list);
    }
    @GetMapping("/propertyBuildingDistribution")
    @ApiOperation("各楼栋房屋数量统计图")
    @OperationLog(description = "各楼栋房屋数量统计")
    public R propertyBuildingDistribution() {
        List<StatisticsVo> list= empStatisticsService.propertyBuildingDistribution();
        return R.ok(list);
    }
    @GetMapping("/residentGenderDistribution")
    @ApiOperation("居民性别分布图")
    @OperationLog(description = "居民性别分布")
    public R residentGenderDistribution() {
        List<StatisticsVo> list= empStatisticsService.residentGenderDistribution();
        return R.ok(list);
    }
    @GetMapping("/complaintStatusDistribution")
    @ApiOperation("投诉处理状态分布图")
    @OperationLog(description = "投诉处理状态分布")
    public R complaintStatusDistribution() {
        List<StatisticsVo> list = empStatisticsService.complaintStatusDistribution();
        return R.ok(list);
    }

    @GetMapping("/parkingStatusDistribution")
    @ApiOperation("停车位使用情况统计图")
    @OperationLog(description = "停车位使用情况统计")
    public R parkingStatusDistribution() {
        List<StatisticsVo> list = empStatisticsService.parkingStatusDistribution();
        return R.ok(list);
    }

    @GetMapping("/topProducts")
    @ApiOperation("热销商品销售数量排行图")
    @OperationLog(description = "热销商品销售数量排行")
    public R topProducts() {
        List<StatisticsVo> list = empStatisticsService.topProducts();
        return R.ok(list);
    }

    @GetMapping("/healthServicesDistribution")
    @ApiOperation("健康服务预约类型占比图")
    @OperationLog(description = "健康服务预约类型占比")
    public R healthServicesDistribution() {
        List<StatisticsVo> list = empStatisticsService.healthServicesDistribution();
        return R.ok(list);
    }

    @GetMapping("/maintenanceTrend")
    @ApiOperation("每月维修请求数量趋势图")
    @OperationLog(description = "每月维修请求数量")
    public R maintenanceTrend() {
        List<StatisticsVo> list = empStatisticsService.maintenanceTrend();
        return R.ok(list);
    }

}
